<?php
require 'LinkedList.php';

$linkedList = new LinkedList();
$linkedList->addFirst("aa");
$linkedList->addFirst("bb");
$linkedList->addFirst("cc");
$linkedList->addFirst("dd");
$linkedList->addFirst("ee");
$linkedList->addFirst("ff");
$linkedList->addFirst("gg");
$linkedList->addFirst("hh");
$linkedList->addFirst("ii");
echo $linkedList->get(3); //获取索引 index = 3 位置的元素 打印 ff
echo "<br>";
echo $linkedList->toString(); //打印 ii->hh->gg->ff->ee->dd->cc->bb->aa->null

$linkedList->add(3, "100");
echo "<br>";
echo $linkedList->toString(); //打印 ii->hh->gg->100->ff->ee->dd->cc->bb->aa->null

$linkedList->remove(2);
echo "<br>";
echo $linkedList->toString(); //打印 ii->hh->100->ff->ee->dd->cc->bb->aa->null

$linkedList->removeFirst();//删除链表头元素
echo "<br>";
echo $linkedList->toString(); //打印 hh->100->ff->ee->dd->cc->bb->aa->null

$linkedList->removeLast();//删除链表末尾元素
echo "<br>";
echo $linkedList->toString(); //打印 hh->100->ff->ee->dd->cc->bb->null
